﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using THSERP.BusinessEntities;
using THSERP.BaseProvider;
namespace THSERP.Modules.POS
{
    public class SubBRPOSItemsGridControl : THSGridControl 
    {
        private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
        public override void InitializeControl()
        {
            base.InitializeControl();
            this.UseEmbeddedNavigator = false;
        }
        public override void InitGridControlDataSource()
        {
            //base.InitGridControlDataSource();
            POSEntities entity = (POSEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
            BindingSource bds = new BindingSource();
            bds.DataSource = entity.BRPOSItemsList;
            this.DataSource = bds;
        }

        //protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        //{
        //    //Check edit item privilege for gridview_Hieu.nguyen_29/04/2010
        //    DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
        //    POSEntities entity = (POSEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
        //    if(entity.Module.HasPrivilege("EditItem"))
        //    {
        //        if (gridView.Columns["BRPOSItemProductQty"] != null)
        //            gridView.Columns["BRPOSItemProductQty"].OptionsColumn.AllowEdit = true;
        //        if (gridView.Columns["BRPOSItemProductUnitPrice"] != null)
        //            gridView.Columns["BRPOSItemProductUnitPrice"].OptionsColumn.AllowEdit = true;
        //        if (gridView.Columns["BRPOSItemProductDesc"] != null)
        //            gridView.Columns["BRPOSItemProductDesc"].OptionsColumn.AllowEdit = true;
        //    }

        //    return gridView;
        //}
        protected override void InitGridViewColumns(DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
             base.InitGridViewColumns(gridView);
            POSEntities entity = (POSEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
            if (gridView.Columns["FK_ICProductID"] != null)
                gridView.Columns["FK_ICProductID"].VisibleIndex = 0;
            if (gridView.Columns["BRPOSItemProductQty"] != null)
                gridView.Columns["BRPOSItemProductQty"].VisibleIndex = 1;
            if (gridView.Columns["BRPOSItemProductUnitPrice"] != null)
                gridView.Columns["BRPOSItemProductUnitPrice"].VisibleIndex = 2;
            if (gridView.Columns["BRPOSItemTotalAmount"] != null)
                gridView.Columns["BRPOSItemTotalAmount"].VisibleIndex = 3;
            if (gridView.Columns["BRPOSItemProductDesc"] != null)
                gridView.Columns["BRPOSItemProductDesc"].VisibleIndex = 4;
        }
        

        protected override string GetLookupTableDisplayColumn(string strLookupTableName)
        {
            switch (strLookupTableName)
            {
                case "ICProducts":
                    return "ICProductName";
                case"GELocations":
                    return "GELocationName";
                default:
                    return base.GetLookupTableDisplayColumn(strLookupTableName);
            }
        }
    }
}
